package com.zfsmart.helper;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.zfsmart.bean.DimDateBean;

import java.time.LocalDate;
import java.util.List;

/**
 * @author xuetieqi
 * @date 2023/2/18 11:32 AM
 **/
public class DimDateHelper {

    public DimDateBean trans(String dateStr) {
        DimDateBean res = new DimDateBean();


        DateTime dateTime = DateUtil.parseDate(dateStr);
        LocalDate localDate = LocalDateTimeUtil.parseDate(dateStr);

        res.setDateId(dateStr);
        res.setWeekId(DateUtil.weekOfYear(dateTime));
        res.setWeekDay(DateUtil.dayOfWeekEnum(dateTime).getIso8601Value());
        res.setDay(localDate.getDayOfMonth());
        res.setYear(localDate.getYear());
        res.setQuarter(DateUtil.quarter(dateTime));
        res.setMonth(localDate.getMonthValue());
        if (res.getWeekDay() >= 6) {
            res.setIsWorkDay(0);
        } else {
            res.setIsWorkDay(1);
        }
        res.setHolidayId("\\N");
        return res;
    }
}
